﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Mappings;

namespace Apollo
{
    [NHibernateEntity(Table = "Contracts", Lazy = true)]
    public class Contract : ITrackable, ILegacy
    {
        public Contract() { }

        [PrimaryKey]
        public virtual int Id { get; set; }

        [Property]
        public virtual string Name { get; set; }


        [BelongsTo(Column = "ID_Account")]
        public virtual Account Account { get; set; }


        [BelongsTo(Column = "ID_Parent_Contract")]
        public virtual Contract Parent { get; set; }

        [Property]
        public virtual PaymentFrequency PaymentFrequency { get; set; }


        [Property]
        public virtual ContractType ContractType { get; set; }

        [Property]
        public virtual DateTime StartDate { get; set; }

        [Property]
        public virtual DateTime? EndDate { get; set; }

        [Property]
        public virtual double SoldValue { get; set; }

        [Property]
        public virtual double GrossValueTotal { get; set; }

        [Property]
        public virtual double GrossValuePrincipal { get; set; }

        [Property]
        public virtual double GWP { get; set; }

        [Property]
        public virtual double InsuredValue { get; set; }


        [Property]
        public virtual double ExtraPremiumMedical { get; set; }

        [Property]
        public virtual double ExtraPremiumProfessional { get; set; }

        [Property]
        public virtual double ExtraPremiumOther { get; set; }


        [Property]
        public virtual int YearDuration { get; set; }


        [BelongsTo(Column = "ID_Currency")]
        public virtual Currency Currency { get; set; }

        
        [BelongsTo(Column = "ID_ContractedBy_Employee")]
        public virtual Employee ContractedBy { get; set; }
        
        [BelongsTo(Column = "ID_Owner_Employee")]
        public virtual Employee Owner { get; set; }


        [Property]
        public virtual string LegacyApplication { get; set; }

        [Property]
        public virtual string LegacyID { get; set; }


        [Property]
        public virtual DateTime InsertDate { get; set; }

        [Property]
        public virtual string InsertBy { get; set; }

        [Property]
        public virtual DateTime? ModifiedDate { get; set; }

        [Property]
        public virtual string ModifiedBy { get; set; }

        [Property]
        public virtual DateTime IssueDate { get; set; }

        [Property]
        public virtual DateTime? SurrenderDate { get; set; }

        [Property]
        public virtual DateTime? ClaimDate { get; set; }

        [Property]
        public virtual DateTime? MaturityDate { get; set; }

        [Property]
        public virtual ContractState ContractState { get; set; }

        [Property]
        public virtual DateTime? ContractStateModifiedDate { get; set; }

        [Property]
        public virtual string PaymentMode { get; set; }

        [Property]
        public virtual DateTime? InitialStartDate { get; set; }

        [Property]
        public virtual int? InitialYearDuration { get; set; }

        [Property]
        public virtual double? ExchangeRate { get; set; }

        [Property]
        public virtual double? Loading { get; set; }
        
        [BelongsTo(Column = "ID_Position_Initial")]
        public virtual Office PositionInitial { get; set; }

        [BelongsTo(Column = "ID_Product")]
        public virtual Product BaseProduct { get; set; }
    }

    public enum ContractType { 
        Main = 0,
        Rider = 1,
    }

    public enum ContractState { 
        Activa = 1,
        ANULATA = 2,
        Lapsed = 3,
        Rascumparata = 4,
        PaidUp_cu_reactivare = 5,
        Expirata_deces = 6,
        Contract_finalizat = 7,
        Activa_scut_plata_prima_deces = 8,
        Activa_scut_proc_plata_prima_invaliditate = 9,
        Activa_scut_plata_prima_imbol_grava = 10,
        Expirata_Risturn_de_prima = 11,
        Transformata = 12,
        Abandonata = 13,
        Maturitate = 14,
        Lapse_cu_reactivare = 15,
        Reziliata_fara_reactivare = 16,
        PaidUp = 17,
        Suspendata = 18,
        Maturitate_notificat = 19,
        Rascumparat_notificat = 20,
        Activa_scut_plata_prime_acc = 563441718
    }
}
